package com.lzl.springboot.controller;

import com.lzl.springboot.bean.Employee;
import com.lzl.springboot.mapper.EmployeeMapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("employee")
@Api(value = "雇员controller",tags="雇员相关操作")
public class EmployeeMybatisConroller {
    @Autowired
    private EmployeeMapper employeeMapper;

    @ApiOperation(value = "查询雇员服务",notes = "根据雇员id查询某个雇员")
    @ApiImplicitParam(name="id",value = "雇员ID",required = true,dataType ="String",paramType = "path")
    @RequestMapping("/findOne/{id}")
    public Employee findOne(@PathVariable("id")String id) {
        return employeeMapper.findOne(id);
    }

    @ApiOperation(value = "雇员列表服务",notes = "查詢所有雇员的列表信息")
    @RequestMapping("/list")
    public List<Employee> list() {
        return employeeMapper.list();
    }

    @ApiOperation(value = "保存雇员服务",notes = "保存单个雇员信息")
    @RequestMapping("/save")
    public String save(Employee employee){
        employeeMapper.save(employee);
        return employee.getId();
    }

    @ApiOperation(value = "查询雇员服务a",notes = "根据雇员id查询某个雇员")
    @ApiImplicitParam(name="id",value = "雇员ID",required = true,dataType ="String",paramType = "path")
    @RequestMapping("/findOnea/{id}")
    public Map findOneByXml1(@PathVariable("id")String id){
        return employeeMapper.findByXmla(id);
    }

    @ApiOperation(value = "查询雇员服务b",notes = "根据雇员id查询某个雇员")
    @ApiImplicitParam(name="id",value = "雇员ID",required = true,dataType ="String",paramType = "path")
    @RequestMapping("/findOneb/{id}")
    public Employee findOneByXml2(@PathVariable("id")String id){
        return employeeMapper.findByXmlb(id);
    }
}
